package com.ssm.interceptor;

import com.ssm.entity.ElcBlacklist;
import com.ssm.service.ElcBlacklistService;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;

@Component
public class BlackFilter {


    @Resource
    private ElcBlacklistService elcBlacklistService;

    private List<ElcBlacklist> elcBlacklists;

//
//    public BlackFilter(){
//
//    }
//
//
//    //    对象创建后就执行的方法
//    @PostConstruct
//    public  void init(){
//
//    }

    public  String  filterWorld(String world){
        elcBlacklists= elcBlacklistService.queryAll(new ElcBlacklist());
        for (ElcBlacklist elcBlacklist:elcBlacklists){
            world=world.replaceAll(elcBlacklist.getDetail(),"***");
        }
        return world;

    }



}
